package cn.pzhu.javaee.webapp.config;

import java.util.HashMap;
import java.util.Map;

public class WebAppConfig {
	public final static String Portal_CONFIG_FILE = "webapp.properties";
	/**
	 * 保存全局属性值
	 */
	private static Map<String, String> map =new HashMap<String, String>();

	/**
	 * 属性文件加载对象
	 */
	private static PropertiesLoader propertiesLoader = new PropertiesLoader(
			Portal_CONFIG_FILE);

	/**
	 * 获取配置
	 */
	public static String getConfig(String key) {
		String value = map.get(key);
		if (value == null) {
			value = propertiesLoader.getProperty(key);
			map.put(key, value);
		}
		return value;
	}
	
	public static String getAppName(){
		return getConfig("AppName");
	}
	public static String getDBUrl(){
		return getConfig("DB_URL");
	}
	public static String getDBUser(){
		return getConfig("DB_USER");
	}
	public static String getDBPassword(){
		return getConfig("DB_PASSWORD");
	}
	
	

}
